<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="changeIsShow">点击切换</button>
        <template v-if="isShow">
           <h3>{{goodData.name}}</h3>
           <h3>{{goodData.age}}</h3>
           <h3>{{goodData.sex}}</h3>
           <h3>{{goodData.hobby}}</h3>
        </template>
        <hr>
        <button @click="changeState(1)">音乐</button>
        <button @click="changeState(2)">新闻</button>
        <button @click="changeState(3)">娱乐</button>
        <button @click="changeState(4)">打豆豆</button>
        <button @click="changeState(5)">炫饭</button>
        <h3 v-if="state === 1">{{newList[0]}}</h3>
        <h3 v-if="state === 2">{{newList[1]}}</h3>
        <h3 v-if="state === 3">{{newList[2]}}</h3>
        <h3 v-if="state === 4">{{newList[3]}}</h3>
        <h3 v-if="state === 5">{{newList[4]}}</h3>
    </div>
    <script>
        const vm = new Vue({
            data(){
                return{
                    isShow:true,
                    goodData:{
                        name:"张三",
                        age:"18",
                        sex:"男",
                        hobby:["打篮球","敲代码","看电影"]
                    },
                    newList:["音乐...","新闻...","娱乐...","打豆豆.。。","炫饭。。。"],
                    state : 1
                }
            },
            methods:{
                changeIsShow(){
                    this.isShow = !this.isShow
                },
                changeState(val){
                    this.state = val
                }
            }
        }).$mount("#app")
    </script>
</body>

</html>